<template>
  <!-- 个人中心-详情-->
  <div class="TaskDetail">
    <div class="side_1"></div>
    <span class="add_1">任务详情</span>
    <el-button type="info" icon="el-icon-back" class="btn_fanhui" @click="Fh">返回</el-button>
    <div class="body">
      <el-steps :active="item.currentStep" align-center class="step">
        <el-step
          :title="ite.RoleName"
          :description="ite.CreateOn"
          v-for="ite in stepList"
          :key="ite.StepId"
        ></el-step>
      </el-steps>
      <div class="form_body">
        <table style="width:60%;margin:20px auto;">
          <tr style="height:60px;">
            <td class="td_1">任务主题</td>
            <td>{{ item.title }}</td>
          </tr>
          <tr style="height:60px;">
            <td class="td_1">任务内容</td>
            <td>{{ item.main }}</td>
          </tr>

          <tr style="height:60px;">
            <td class="td_1">任务类型</td>
            <td>{{ item.typeStr }}</td>
          </tr>
          <tr style="height:60px;">
            <td class="td_1">完成日期</td>
            <td>{{ item.date }}</td>
          </tr>
          <tr style="height:60px;">
            <td class="td_1">接收人</td>
            <td>{{ item.receiver }}</td>
          </tr>
          <tr v-for="(refusalitem,index) in refusalReasonList" style="height:60px;">
            <td class="td_1">驳回理由</td>
            <td>{{ refusalitem.main }}</td>
          </tr>
        </table>
      </div>
    </div>
    <div class="btn_bottom">
      <el-button type="primary" size="medium" @click="caozuo(1)" v-show="item.paixu==1&shows==0">接收</el-button>
      <el-button type="primary" size="medium" @click="caozuo(2)" v-show="item.paixu==2&shows==0">完成</el-button>
      <el-button type="primary" size="medium" @click="caozuo(3)" v-show="item.paixu==3&shows==0">确定</el-button>
      <el-button type="primary" size="medium" @click="refusalVisible=true" v-show="item.paixu==3&shows==0">驳回</el-button>
    </div>
    <!--驳回弹框-->
    <el-dialog
      title="驳回理由"
      append-to-body
      :visible.sync="refusalVisible"
      width="30%"
      >
     <el-input style="" type="textarea" :autosize="{ minRows: 2, maxRows: 5}" v-model="refusalReason"></el-input>
      <span slot="footer" class="dialog-footer">
    <el-button @click="refusalVisible = false">取 消</el-button>
    <el-button type="primary" @click="confirmRefusal()">确 定</el-button>
  </span>
    </el-dialog>
  </div>
</template>

<script>
import axios from 'axios'

export default {
  data() {
    return {
      refusalReason:"",
      refusalReasonList:[],
      refusalVisible:false,
      id: 0,
      shows: 0,
      item: {
        id: 0,
        title: '',
        main: '',
        date: '',
        typeStr: "",
        receiver: "",
        creater: "",
        paixu: 0,
        currentStep: 1
      },
      stepList: [],
      Mark: 0,
    }
  },
  created() {
    this.creater = JSON.parse(localStorage.getItem("message")).Id;
    //地址栏传参
    this.id = this.$route.query.e;
    this.shows = this.$route.query.shows;
    this.getData()
  },
  methods: {
    confirmRefusal(){
      if (this.refusalReason == "") {
        this.$message.error("驳回理由不能为空");
        return;
      } else {
        this.caozuo(4)
        this.refusalVisible = false
      }
    },
    caozuo(e) {
      if (this.Mark == 0) {
        var obj = {id: this.id, state: e, creater: this.creater,refusalReason:this.refusalReason};
        var objs = JSON.stringify(obj);
        let the = {index: 1, jsondata: objs};
        this.Mark = 1;
        axios.post("/apis/MyCenter.asmx/Examine", the).then(({data}) => {
          var list = JSON.parse(data.d);
          if (list.flag == true) {
            this.$message.success(list.tip);
            setTimeout(() => {
              window.history.go(-1);
            }, 500);
          } else {
            this.$message.error(list.tip);
          }
        })
      }
    },
    //  返回
    Fh() {
      window.history.go(-1);
    },
    //获取数据
    getData() {
      var obj = {id: this.id, creater: this.creater};
      var objs = JSON.stringify(obj);
      let the = {index: 3, jsondata: objs};
      console.log(obj)
      axios.post("/apis/MyCenter.asmx/GetData", the).then(({data}) => {
        var list = JSON.parse(data.d);
        console.log(list)
        this.refusalReasonList=list.refusalList;
        if (list == null) {
          this.$message.error("数据异常");
        } else {
          this.item = list.basemess;
          this.stepList = list.stepList
        }
        console.log(this.stepList)
      })
    }
  }
}
</script>

<style lang="scss" scoped>
@import '@/assets/scss/base.scss';

.TaskDetail .body {
  width: 98%;
  height: 600px;
  background-color: $white;
  margin-left: 10px;
  margin-top: 40px;
  overflow: hidden;
}

.step {
  margin-top: 50px;
}

.side_1 {
  width: 5px;
  height: 16px;
  background-color: $Header_color;

  margin-left: 10px;
  margin-top: 30px;
}

.add_1 {
  margin-left: 20px;
  margin-top: -20px;
  float: left;
  font-size: 18px;
  font-weight: 400;
}

.btn_fanhui {
  margin-top: -20px;
  margin-right: 20px;
  float: right;
}

table,
table tr th,
table tr td {
  border: 1px solid #e7e7e7;
  margin-top: 80px;
  text-align: center;
}

.table {
  width: 70%;
  margin-left: 15%;
}

.td_1 {
  width: 180px;
  text-align: center;
  background-color: $DaohangBg_color;
}

.body {
  width: 98%;
  height: 800px;
  background-color: $white;
  margin-left: 10px;
  margin-top: 50px;
  overflow: hidden;
}

.btn_bottom {
  margin-top: 50px;
  margin-left: 45%;
}
</style>
